<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>左侧菜单树</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>

<script src="${_resources}js/jquery.ztree.core.js" type="text/javascript"></script>
<link href="${_resources}css/zTreeStyle.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="${_resources}js/jquery.ztree.excheck.js"></script>
<link href='${_resources}css/style.css' type='text/css' rel='stylesheet' />

<script type="text/javascript">
var menuId ="${menuId}";
var parentId ="${parentId}";
	var ztree;
	var setting = {	
		view: {
			 showIcon: false,
             dblClickExpand: false,
             showLine: true
         },	
	   	  check: {
	          enable: false,
	          chkStyle: "radio",
	  		  radioType: "all"
	      },	
		 data: {
             simpleData: {
                 enable: true,
                 idKey:"menuId", 
                 pIdKey:"parentId"
             },
             key :{
            	 name :"menuName"
             }
         },
		callback: {
			/* onNodeCreated: this.onNodeCreated,		 */		
			//onClick:onClick
		}
	};
	
	 var zNodes = ${firstMenuList};

    /*  function onClick(e,treeId, treeNode) {

         console.info(treeNode);
         var zTree = $.fn.zTree.getZTreeObj("treeDemo");
         zTree.expandNode(treeNode);
         zTree.checkNode(treeNode, true, null, null);
     } */
     
   
     
	$(document).ready(function(){
		var ztree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        var node = ztree.getNodeByParam('menuId',parentId);
        ztree.selectNode(node);
        ztree.expandAll(true);
	});
	
	 function save(){
         var treeObj=$.fn.zTree.getZTreeObj("treeDemo");
         var nodes = treeObj.getSelectedNodes();
         //获取选中节点的值
         parent.$("#parentName").val(nodes[0].menuName);
         parent.$("#parentId").val(nodes[0].menuId);
         var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
         parent.layer.close(index);
     }
	
</script>
</head>
<body>
<!-- <div class="main" style="overflow: hidden;">
   <div class="submenu_div" style="overflow: inherit;">
       <ul id="treeDemo" class="ztree"></ul>
    </div>
    <div class="permission_an mubanclass_an ma">
        <a href="javascript:;" class="per_baocun" onClick="onClick();">确定</a>
    </div>
</div>
 -->
<div class="permission" style="width:98%;margin:auto; padding-bottom:40px;">
    <table id="example-basic" class="treetable">
     <ul id="treeDemo" class="ztree"></ul>
   </table>
    <div class="permission_an mubanclass_an ma">
    <a href="javascript:;" class="per_baocun" style="" onClick="save();">确定</a>
    </div>
</div>
</body>
</html>
